#    找Eigen3库
#   若找到，会定义如下变量：
#   Eigen3_FOUND --->   系统有Eigen3k库
#   Eigen3_INCLUDE_DIR = EIGEN3_INCLUDE_DIRS = EIGEN3_INCLUDE_DIRECTORY = EIGEN3_INCLUDE_DIRECTORIES   --->   Eigen3库的头文件路径

#  copyright (c) 2020 我的就是你的

if (Eigen3_INCLUDE_DIR)
   set(Eigen3_FOUND TRUE) #在缓存中已经被加载过
else ()
    find_path(EIGEN3_INCLUDE_DIR 
        NAMES Eigen/Core
        PATH_SUFFIXES eigen3
        HINTS  /usr/include/eigen3 /usr/include/ /usr/local/include/eigen3 /usr/local/include )

    # 给EIGEN3_INCLUDE_DIR几个别名
    set(EIGEN3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR} )
    set(EIGEN3_INCLUDE_DIRECTORY ${EIGEN3_INCLUDE_DIR})
    set(EIGEN3_INCLUDE_DIRECTORIES ${EIGEN3_INCLUDE_DIR})
    set(Eigen3_INCLUDE_DIR ${EIGEN3_INCLUDE_DIR})
    set(Eigen3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR} )
    set(Eigen3_INCLUDE_DIRECTORY ${EIGEN3_INCLUDE_DIR})
    set(Eigen3_INCLUDE_DIRECTORIES ${EIGEN3_INCLUDE_DIR})


    
    #如果Eigen3在所指示的路径中找到，则自动设置Eigen3_FOUND为TRUE
    include(FindPackageHandleStandardArgs)
    #find_package_handle_standard_args(Eigen3 DEFAULT_MSGS EIGEN3_INCLUDE_DIR)
    find_package_handle_standard_args(Eigen3 FOUND_VAR Eigen3_FOUND
                            REQUIRED_VARS EIGEN3_INCLUDE_DIR
                            FAIL_MESSAGE "can't find Eigen3 in directory '/usr/include /usr/local/include' ")

    mark_as_advanced(EIGEN3_INCLUDE_DIR)
    endif ()
